﻿using System;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RemoteUser
{
    public class TCPConnection
    {

        private IPAddress serverIp = null;
        private int serverPort;
        private TcpClient tcpClient = null;//为 TCP 网络服务提供客户端连接

        public NetworkStream netstream {  get;set; }

        public Socket myClientSocket { get; set; }

        public TCPConnection(IPAddress ip, int port)
        {
            serverIp = ip;
            serverPort = port;
        }

        public TcpClient Connect()
        {
            try
            {
                tcpClient = new TcpClient();
                tcpClient.Connect(serverIp, serverPort);//连接到服务
            }
            catch (Exception)
            {
                return null;
            }
            return tcpClient;
        }
    }
}
